home *** CD-ROM | disk | FTP | other *** search
- /*
- ------------------------------------------------------------------------------
- | Sun Microsystems, TOPS Division
- | 950 Marina Village Parkway
- | P.O. Box 4016
- | Alameda, CA 94501
- |
- | Copyright (c) 1989 Sun Microsystems, Inc. All rights reserved.
- |
- | Sun considers its source code as an unpublished, proprietary trade secret,
- | and it is available only under strict license provisions. This copyright
- | notice is placed here only to protect Sun in the event the source is deemed
- | a published work. Disassembly, decompilation, or other means of reducing the
- | object code to human readable form is prohibited by the license agreement
- | under which this code is provided to the user or company in possession of
- | this copy.
- |
- | RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the Government
- | is subject to restrictions as set forth in subparagraph (c) (1) (ii) of the
- | Rights in Technical Data and Computer Software clause at DFARS 52.227-7013
- | and in similar clauses in the FAR and NASA FAR supplement.
- ------------------------------------------------------------------------------
- */
-
-
-
-
- /*
-
- IMPLEMENTATION CSTClientApp
-
- */
-
- #include "CSTClientApp.h"
-
-
- /*** constants ***/
- #define kNumLines (25)
- #define kWindowWidth (400)
- #define kTop (50)
- #define kLeft (10)
-
- /* menu STUFF */
- #define iClearWindow (1)
- #define iDebugger (2)
- #define iQuit (3)
-
- #define mClient (mEdit+1)
- #define iCreateClient (1)
- #define iDestroyClient (2)
- #define iFunction1 (4)
- #define iFunction2 (5)
- #define iFunction3 (6)
- #define iFunction4 (7)
- #define iFunction5 (8)
-
- /* cmd numbers */
- #define cClearWindow (1000)
- #define cDebugger (1008)
- #define cCreateClient (1001)
- #define cDestroyClient (1002)
- #define cFunction1 (1003)
- #define cFunction2 (1004)
- #define cFunction3 (1005)
- #define cFunction4 (1006)
- #define cFunction5 (1007)
-
-
-
- /*** METHODS for CSTClientApp ***/
- void CSTClientApp::ISTClientApp(void) {
- this->IApplication('????');
- this->CreateWindow();
- }
-
- void CSTClientApp::CreateWindow(void) {
- Point p;
- CWriteLnWindow* w = new(CWriteLnWindow);
-
- p.h = kLeft;
- p.v = kTop;
- w->IWriteLnWindow((unsigned char *)"\pClient Window", kNumLines, kWindowWidth, p);
- fWindow = w;
- /* fClient = NIL; */
- }
-
- void CSTClientApp::CreateMenus(void) {
- char appleString[2];
- appleString[0] = 0x1;
- appleString[1] = appleMark;
- fAppleMenu = NewMenu(mApple, appleString);
- AppendMenu(fAppleMenu, "\pAbout Client...;(-");
- AddResMenu(fAppleMenu, 'DRVR');
- InsertMenu(fAppleMenu, 0);
-
- fFileMenu = NewMenu(mFile, "\pFile");
- AppendMenu(fFileMenu, "\pClear Window/W;Debugger/M;Quit/Q");
- InsertMenu(fFileMenu, 0);
-
- fEditMenu = NewMenu(mEdit, "\pEdit");
- AppendMenu(fEditMenu, "\pCut/X;Copy/C;Paste/V");
- InsertMenu(fEditMenu, 0);
-
- fClientMenu = NewMenu(mClient, "\pClient");
- AppendMenu(fClientMenu, "\pOpen/C;Close/D;(-;Function1/1;Function2/2;Function3/3;Function4/4;Function5/5");
- InsertMenu(fClientMenu, 0);
-
- DrawMenuBar();
- }
-
- void CSTClientApp::CreateClient(void) {
- INT32 err;
- Str255 msg;
-
- err = STClientCreate();
- fWindow->WriteLn((unsigned char*)"\pTried to open client. result Code: ");
- NumToString(err,msg);
- fWindow->WriteLn(msg);
- if (err != noErr) {
- SysBeep(1);
- fWindow->WriteLn((unsigned char*)"\pCould not open client. :-(");
- return;
- }
- fWindow->NewLine();
- fWindow->NewLine();
- }
-
- void CSTClientApp::DestroyClient(void) {
- INT32 err;
- Str255 msg;
-
- err = STClientDispose();
- NumToString(err,msg);
- fWindow->WriteLn(msg);
- if (err != noErr) {
- SysBeep(1);
- fWindow->WriteLn((unsigned char*)"\pCould not dispose client. :-(");
- return;
- }
- fWindow->WriteLn((unsigned char*)"\pSuccessfully destroyed client.");
- fWindow->NewLine();
- fWindow->NewLine();
- }
-
-
-
- void CSTClientApp::CallFunction1(void) {
- INT32 err;
- Str255 msg;
-
- err = Func1();
- fWindow->WriteLn((unsigned char*)"\p==> Func1: result Code = ");
- NumToString(err,msg);
- fWindow->WriteLn(msg);
- fWindow->NewLine();
- fWindow->NewLine();
- }
-
- void CSTClientApp::CallFunction2(void) {
- INT32 err;
- Str255 msg;
- static INT32 arg = 0L;
-
- arg++;
- err = Func2(arg);
- fWindow->WriteLn((unsigned char*)"\p==> Func2: result Code = ");
- NumToString(err,msg);
- fWindow->WriteLn(msg);
- fWindow->NewLine();
- fWindow->NewLine();
- }
-
- void CSTClientApp::CallFunction3(void) {
- INT32 err;
- Str255 msg;
- static INT32 arg1 = 0;
- static INT16 arg2 = 20;
-
- arg1++;
- arg2++;
- err = Func3(arg1,arg2);
- fWindow->WriteLn((unsigned char*)"\p==> Func3: result Code = ");
- NumToString(err,msg);
- fWindow->WriteLn(msg);
- fWindow->NewLine();
- fWindow->NewLine();
- }
-
- void CSTClientApp::CallFunction4(void) {
- INT32 err;
- Str255 msg;
- char* arg = "hello out there";
-
- err = Func4(arg);
- fWindow->WriteLn((unsigned char*)"\p==> Func4: result Code = ");
- NumToString(err,msg);
- fWindow->WriteLn(msg);
- fWindow->NewLine();
- fWindow->NewLine();
- }
-
- void CSTClientApp::CallFunction5(void) {
- INT32 err;
- Str255 msg;
- Str255 pStr = (unsigned char*)"\pnever say never";
-
- err = Func5(pStr);
- fWindow->WriteLn((unsigned char*)"\p==> Func5: result Code = ");
- NumToString(err,msg);
- fWindow->WriteLn(msg);
- fWindow->NewLine();
- fWindow->NewLine();
- }
-
-
-
- INT16 CSTClientApp::MenuSelectionToCmd(INT16 menu, INT16 item) {
- INT16 returnValue = cNoCmd;
-
- switch (menu) {
- case mFile:
- switch(item) {
- case iClearWindow:
- returnValue = cClearWindow;
- break;
-
- case iDebugger:
- returnValue = cDebugger;
- break;
-
- case iQuit:
- returnValue = cQuit;
- break;
- }
- break;
-
- case mClient:
- switch(item) {
- case iCreateClient:
- returnValue = cCreateClient;
- break;
-
- case iDestroyClient:
- returnValue = cDestroyClient;
- break;
-
- case iFunction1:
- returnValue = cFunction1;
- break;
-
- case iFunction2:
- returnValue = cFunction2;
- break;
-
- case iFunction3:
- returnValue = cFunction3;
- break;
-
- case iFunction4:
- returnValue = cFunction4;
- break;
-
- case iFunction5:
- returnValue = cFunction5;
- break;
-
- }
- break;
-
- default:
- returnValue = inherited::MenuSelectionToCmd(menu,item);
- }
-
- return(returnValue);
- }
-
-
- void CSTClientApp::DoMenuCmd(INT16 cmd) {
- switch (cmd) {
- case cClearWindow:
- this->DoClear();
- break;
-
- case cDebugger:
- this->DoDebugger();
- break;
-
- case cCreateClient:
- this->DoCreateClient();
- break;
-
- case cDestroyClient:
- this->DoDestroyClient();
- break;
-
- case cFunction1:
- this->DoFunction1();
- break;
-
- case cFunction2:
- this->DoFunction2();
- break;
-
- case cFunction3:
- this->DoFunction3();
- break;
-
- case cFunction4:
- this->DoFunction4();
- break;
-
- case cFunction5:
- this->DoFunction5();
- break;
-
- default:
- inherited::DoMenuCmd(cmd);
- break;
- }
- }
-
-
- /** menu actions **/
- void CSTClientApp::Quit(void) {
- this->DestroyClient();
- inherited::Quit();
- }
-
- void CSTClientApp::DoClear(void) {
- fWindow->ClearContents();
- fWindow->Invalidate();
- }
-
- void CSTClientApp::DoDebugger(void) {
- Debugger();
- }
-
- void CSTClientApp::DoCreateClient(void) {
- this->CreateClient();
- }
-
- void CSTClientApp::DoDestroyClient(void) {
- this->DestroyClient();
- }
-
- void CSTClientApp::DoFunction1(void) {
- this->CallFunction1();
- }
-
- void CSTClientApp::DoFunction2(void) {
- this->CallFunction2();
- }
-
- void CSTClientApp::DoFunction3(void) {
- this->CallFunction3();
- }
-
- void CSTClientApp::DoFunction4(void) {
- this->CallFunction4();
- }
-
- void CSTClientApp::DoFunction5(void) {
- this->CallFunction5();
- }
-
-
-
-